package com.admin.controller;


import com.admin.es.entity.EsSchoolActivityEntity;
import com.admin.user.entity.SchoolActivity;
import com.admin.service.SchoolActivityService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学校活动管理controller
 * @author 武佳敏
 * @date 2023-02-01
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/schoolActivity")
public class SchoolActivityController {

    @Autowired
    SchoolActivityService schoolActivityService;

    /**
     * 条件查询学校活动列表
     * @author 武佳敏
     * @date 2023-02-01
     */
    @GetMapping()
    public List<EsSchoolActivityEntity> getList(SchoolActivity schoolActivity){
        List<EsSchoolActivityEntity> list=schoolActivityService.getList(schoolActivity);
        return list;
    }

    /**
     * 删除es中的数据
     * @author 武佳敏
     * @date 2023-02-01
     */
    @DeleteMapping("/delEsAllData")
    public void deleteEsData(){
        schoolActivityService.deleteEsData();
    }

    /**
     * 新增学校活动
     * @author 武佳敏
     * @date 2023-02-01
     */
    @PostMapping("/add")
    public void add(@RequestBody SchoolActivity schoolActivity){
        schoolActivityService.add(schoolActivity);
    }

    /**
     * 通过id修改学校活动
     * @author 武佳敏
     * @date 2023-02-01
     */
    @PutMapping()
    public void updateById(@RequestBody SchoolActivity schoolActivity){
        schoolActivityService.updateById(schoolActivity);
    }

    /**
     * 通过id删除学校活动
     * @author 武佳敏
     * @date 2023-02-01
     */
    @DeleteMapping("/delById")
    public void delById(Long id){
        schoolActivityService.delById(id);
    }




}
